VideoHelp.com Forum
+ Reply to Thread
Results 1 to 5 of 5
Thread
  1. Member
    Join Date: Mar 2006
    Location: Denmark
    Hi everybody.

    I would like to build a little encoder application that uses CMD line executeables to do the work.
    A problem i havent found a solution to, is how to get the contents of a CMD prompt in progress.

    Alltho i TOTAL noob in C++ , i managed to create another .dll application once for a game, that did something like it. (getting text from game console) and it was using WM_GETTEXT

    So, i'm convinced that i can use WM_GETTEXT in c++ to get the contents of 8any) window.. but i dont' know exaclty how to.. =/


    Code:
    Here's the fundamental stuff of my old similar project
    #include "dll.h"
    #include <windows.h> 
    using namespace std;
    #pragma warning(disable:4129) 
    #define PARENTWND "Console" 
    #define CHILDWND "Edit" 
    #define MAX_BUFFER 16384  
    #define CR 13 
    #define LF 10 
    
    static HWND hwndParent        = NULL; 
    static HWND hwndEdit          = NULL; 
    static HWND hwndConsole       = NULL; 
    void SetWindowHandles(){ 
       hwndParent   = FindWindow(0, PARENTWND); 
       hwndEdit   	= FindWindowEx(hwndParent, NULL, CHILDWND, NULL); 
       hwndConsole   = FindWindowEx(hwndParent, hwndEdit, CHILDWND, NULL); 
       } 
    char* GetTextFromWindow() { 
          SendMessage(hwndConsole, WM_GETTEXT, (WPARAM)sizeof(consolestream), (LPARAM)consolestream);
    return consolestream;
    }
    
    
    int main(){ 
        SetWindowHandles(); 
    }
    Any pointers would be highly apreciated
    Quote Quote  

  2. Member midders's Avatar
    Join Date: Sep 2008
    Location: United Kingdom
    There's a possible solution here, but I'm wondering why it is you want to capture the output in the first place. If you want to show progress, then why not just bring the cmd window into the foreground. Or is it for some other reason?

    Also, if you're going to be using command line tools for all the work, then why not just write a batch file, rather than diving in to C++. Check out the link in my sig for an example.

    Slainte

    midders
    Quote Quote  

  3. Member
    Join Date: Dec 2005
    Location: none
    Originally Posted by midders
    why not just bring the cmd window into the foreground...
    why not just write a batch file...
    Because it's ugly? Ugly doesn't bother me but it bothers many people.
    Quote Quote  

  4. Man of Steel freebird73717's Avatar
    Join Date: Dec 2003
    Location: Smallville, USA
    Google search for "redirect stdout to a textbox"
    Donadagohvi (Cherokee for "Until we meet again")
    My Video Tools :: Free Security Software :: Ubuntu Antivirus Rescue CD
    Quote Quote  

  5. Member midders's Avatar
    Join Date: Sep 2008
    Location: United Kingdom
    Originally Posted by freebird73717
    Google search for "redirect stdout to a textbox"
    Many of the command line tools don't output to stdout or stderr, or at least attempts to redirect these output streams to files in a command window are ineffectual.

    Originally Posted by jagabo
    Because it's ugly? Ugly doesn't bother me but it bothers many people.
    If you say so. I guess beauty is in the eye of the beerholder.

    A quick fix solution would be to run the command line tool in a child window of your main application; then you can move the window around, change it's size and colour etc. however you like.
    Quote Quote  




Similar Threads

  1. how to run as admin in CMD in Windows XP?
    By jyeh74 in forum Newbie / General discussions
    Replies: 7
    Last Post: 29th Jan 2010, 18:26
  2. wildcards in cmd
    By cL0N31 in forum Computer
    Replies: 6
    Last Post: 3rd Apr 2009, 20:58
  3. why does ffmpeg progress go to 1000+%?
    By jsegel in forum ffmpegX general discussion
    Replies: 1
    Last Post: 8th Oct 2008, 22:14
  4. Video info tool (cmd-line-way) wich one?
    By squadjot in forum Video Conversion
    Replies: 2
    Last Post: 19th Sep 2008, 14:01
  5. Replies: 6
    Last Post: 1st Aug 2007, 02:00
Search   Contact us   About   Advertise   Forum   RSS Feeds   Statistics   Tools